package com.nowcoder.code.lcof;

public class JZ56 {

    public int[] FindNumsAppearOnce(int[] nums) {


        int r = nums[0];

        for (int i = 1; i < nums.length; i++) {
            r = nums[i] ^ r;
        }

        int i = 1;
        while ((i & r) != i) {
            i = i << 1;
        }

        int r0 = 0;
        int r1 = 0;

        for (int num : nums) {
            if ((i & num) == i) {
                r0 = r0 ^ num;
            } else {
                r1 = r1 ^ num;
            }
        }
        return new int[]{Math.min(r0, r1), Math.max(r0, r1)};

    }

}
